package com.biz.primus.ms.member.dao.redis;

import com.biz.primus.base.redis.CrudRedisDao;
import com.biz.primus.ms.member.dao.ro.NotificationRo;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository
public class NotificationRedisDao extends CrudRedisDao<NotificationRo, Long>
{

    public NotificationRo findByUserId(Long userId)
    {
        Map<byte[], byte[]> redisBytes = hgetAll(getUserNotificationHashKey(userId));
        NotificationRo notificationRo = new NotificationRo();
        notificationRo.fromMap(redisBytes);
        return notificationRo;
    }

    private String getUserNotificationHashKey(Long userId) {
        return super.getKeyByParams(userId);
    }
}
